<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	
  <link rel="stylesheet" href="${ctx}/css/common.css" type="text/css"></link>
  <link rel="stylesheet" href="${ctx}/css/reset.css" type="text/css"></link>
  <script type='text/javascript' src='${ctx}/dwr/interface/DeptDutyDwr.js'></script>
  <script type='text/javascript' src='${ctx}/dwr/engine.js'></script>
  <script type='text/javascript' src='${ctx}/dwr/util.js'></script>
  <script type="text/javascript" src="${ctx}/js/System/DeptDutyManager.js"></script>
  <script type="text/javascript" src="${ctx}/js/jquery-1.7.2.js"></script>
  <script type="text/javascript" src="${ctx}/js/jquery.easydrag.handler.beta2.js"></script>
  </head>
  
  <body>
  	  <div class="head">
  		<div class="curloc"><span>当前位置: 系统管理>>机构职务维护</span></div>
  	  </div>
	  <div class="query">
	  <form action="" method="post" id="query_form">
	  <div class="querytype">
	  	<label>查询条件：</label>
	  	
	  	<select class="queryselect" id="query_select">
	  		<option value="ddall">
	  		全部
	  		</option>
			<option value="deptname">
			部门名称
			</option>
			<option value="dutyname">
			职务名称
			</option>
		</select>
		<input type="text" id="ddqueryinfo" name="ddqueryinfo"/>
		</div>
	  	<div class="querybtn">
	  		<span class="STYLE1" style="margin-left: 10px"><img src="${ctx}/images/a1.gif" width="9" height="9" /></span>
            <span class="STYLE1"> </span><a style="cursor: pointer;text-decoration: none;color: black;" href="javaScript:queryhref()">查询</a><span class="STYLE1"></span>
           
	  	</div>
	  	<div style="float: right; padding-right: 20px">
	  			<span class="STYLE1"><img src="${ctx}/images/001.gif" width="9" height="9" /></span>
            	<span class="STYLE1"> </span><a href="javaScript:adddepthref()">新增</a><span class="STYLE1"></span>
	  	</div>
      
	  <div class="clear"></div>
	  </form>
	</div>
	 
        <div id="main">
        <table id="detail_t">
          <tr>
          	<th>序号</th>
            <th>部门名称</th>
            <th>职务名称</th>
            <th>岗位总数</th>
            <th>剩余岗位数</th>
            <th>更多操作</th>
          </tr>
           <c:forEach items="${page.list}" var="list" varStatus="status">
         <tr class="items">
         	<td>${status.index+1}</td>
    		<td>${list.dept.name}</td>
    		<td>${list.duty.name}</td>
    		<td>${list.empnum}</td>
    		<td>${list.quenum}</td>
    		<td height="18" bgcolor="#FFFFFF">
    		<div align="center">
            <span class="STYLE1"><img src="${ctx}/images/037.gif" width="9" height="9" /></span>
            <span class="STYLE1"> [</span><a href="javaScript:updatehref('${list.dept.name}','${list.duty.name}','${list.empnum}')">编辑</a><span class="STYLE1">]</span>
            &nbsp;&nbsp;&nbsp;
            <span class="STYLE2"><img src="${ctx}/images/010.gif" width="9" height="9" /></span>
            <span class="STYLE2"> </span><span class="STYLE1">[</span><a href="javascript:void(0)" onclick="Delete('${list.dept.name}','${list.duty.name}')">删除</a><span class="STYLE1">]</span>
            </div>
    	   </td>
        </tr>
    </c:forEach>
      </table>
			<div class="manu">共${page.totalCount}条记录当前第<font color="#ff6600">${page.pageNo}/${page.pageCount}</font>页
				 <a href="DeptDutyManagerServlet?pageNo=${1}">首页</a>
				  <a href="DeptDutyManagerServlet?pageNo=${page.pageNo-1}">上一页</a>
				  <a href="DeptDutyManagerServlet?pageNo=${page.pageNo+1}">下一页</a>
				  <a href="DeptDutyManagerServlet?pageNo=${page.pageCount}">末页</a> 每页显示
				  <input type="text" name="pageSize"  id="pageSize" size="4"/>条
				  <input type="button" value="提交" class="submitbuttton" onclick="changePageSize()"/> 
			</div>
		</div>
		
		<div id="pop_update_div" class="pop_box">
			<div class="p_head">
				<span class="p_h_title">部门职位信息修改</span> <span><a
					class="p_h_close" onclick="hideDiv('pop_update_div');" title="close">X</a>
				</span>
			</div>
			<div class="p_box_body" id="p_b_body">
				<div class="p_con">
				<form action="" id="update_form">
					<table id="p_con_t">
					  <tr>
					    <td class="t1">部门名称：</td>
					    <td>
					    <input type="text" id="update_dept_name" readonly="readonly"/>
					    </td>
					  </tr>
					  <tr>
					    <td class="t1">职位名称：</td>
					    <td>
					    <input type="text" id="update_duty_name" readonly="readonly"/>
					    </td>
					  </tr>
					  <tr>
					    <td class="t1">岗位总数量：</td>
					    <td>
					    <input type="text" id="update_emp_num"/>
						</td>
					  </tr>
					  <tr>
					  	<td></td>
					  	<td class="querybtn"><input type="button" value="修改" onclick="fddupdatebtn()" /></td>
					  </tr>
					</table>
					</form>
				</div>
			</div>
		</div>
		<div id="pop_add_div" class="pop_box">
			<div class="p_head">
				<span class="p_h_title">部门职位添加</span> <span><a
					class="p_h_close" onclick="hideDiv('pop_add_div');" title="close">X</a>
				</span>
			</div>
			<div class="p_box_body" id="p_b_body">
					<div id="new_div" class="p_con">
					  <form action="" id="new_form">
					  <table id="p_con_t">
					  <tr>
					    <td class="t1">部门名称：</td>
					    <td>
					    <select id="new_dept_name">
					    </select>
					    </td>
					  </tr>
					  <tr>
					    <td class="t1">职位名称：</td>
					    <td>
					    <select id="new_duty_name">
					    </select>
					    </td>
					  </tr>
					  <tr>
					    <td class="t1">岗位总数量：</td>
					    <td>
					    <input type="text" id="new_emp_num"/>
						</td>
					  </tr>
					  <tr>
					  	<td></td>
					  	<td class="querybtn"><input  type="button" value="添加" onclick="fddnewbtn()"/></td>
					  </tr>
					</table>
					</form>
				</div>
			</div>
		</div>
</body>
<script type="text/javascript">
function hideDiv(div_id){
            $("#" + div_id).animate({opacity: "hide" }, 300);
}
function popupDiv(div_id) {
            var div_obj = $("#" + div_id);
            //窗口宽度,高度
            var winWidth = $(window).width();
            var winHeight = $(window).height();
            //弹出的div的宽度,高度
            var popHeight = div_obj.height();
            var popWidth = div_obj.width();
            div_obj.animate({
				 opacity: "show", left: (winWidth-popWidth) / 2, top: (winHeight-popHeight)/2,width:popWidth,height:popHeight}, 300);          
}
function adddepthref(){
	var new_dept_name=document.getElementById("new_dept_name");
	DeptDutyDwr.getAllDept(function(data) {
		DWRUtil.removeAllOptions(new_dept_name);
    	DWRUtil.addOptions(new_dept_name,{'':'请选择'});
		DWRUtil.addOptions(new_dept_name,data,'id','name');
	});
	DeptDutyDwr.getAllDuty(function(data) {
		DWRUtil.removeAllOptions(new_duty_name);
    	DWRUtil.addOptions(new_duty_name,{'':'请选择'});
		DWRUtil.addOptions(new_duty_name,data,'id','name');
	});
	popupDiv("pop_add_div");
}
function updatehref(dept_name,duty_name,emp_num){
	document.getElementById("update_dept_name").value=dept_name;
	document.getElementById("update_duty_name").value=duty_name;
	document.getElementById("update_emp_num").value=emp_num;
	popupDiv("pop_update_div");
}
function Delete(dept_name,duty_name) {
        if (confirm("你确认删除这条记录吗?")) {
			DeptDutyDwr.deleteDeptDuty(dept_name,duty_name, function(data) {
				if(data){
					alert("部门职务信息删除成功！");
					location.href="DeptDutyManagerServlet";
				}else{
					alert("抱歉。部门职务信息删除失败！请检验你输入的信息！")
				}
			});
        }
    }
function queryhref(){
	var querydept_index=document.getElementById("query_select").selectedIndex;
	var ddquerytype=document.getElementById("query_select").options[querydept_index].value;
	var ddqueryinfo=document.getElementById("ddqueryinfo").value;
	if("ddall"==ddquerytype){
		document.getElementById("query_form").action="DeptDutyManagerServlet?ddquerytype="+ddquerytype;
		document.getElementById("query_form").submit();
	}else{
		if(""!=ddqueryinfo){
			document.getElementById("query_form").action="DeptDutyManagerServlet?ddquerytype="+ddquerytype;
			document.getElementById("query_form").submit();
		}else{
			alert("请输入查询信息");
			return;
		}
	}
}

$(function() {
            $(".pop_box").easydrag();
            $(".pop_box").setHandler(".pop_box .p_head");
});
</script>
</html>
